home *** CD-ROM | disk | FTP | other *** search
- Path: nntp.teleport.com!sschaem
- From: sschaem@teleport.com (Stephan Schaem)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Integer Sine tables?
- Date: 27 Feb 1996 20:36:42 GMT
- Organization: Teleport - Portland's Public Access (503) 220-1016
- Message-ID: <4gvq0q$qqd@maureen.teleport.com>
- References: <4glqbd$4ab@nnrp1.news.primenet.com> <4gpbi1$3i5@maureen.teleport.com> <1996Feb26.162410.27523@imada.ou.dk>
- NNTP-Posting-Host: linda.teleport.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Bjorn Reese (breese@imada.ou.dk) wrote:
- : Stephan Schaem (sschaem@teleport.com) wrote:
- : > You can alway open the math.library fpu or not... Thats the easyest.
- : > I dont know the incremental methode using integer math, anyone?
-
- : Hey, wait a second. Didn't I send you the C source for the Cordic
- : method once, which you translated into asm? ;)
-
- Did I? my god yea, I totaly forgot :) Well, I will post it then ...
-
- But this is not what I had in mind when I was saying incremental
- function to build a sin table... this function will return the actual
- sin value of any number you feed it.
- The sad thing is I only used it to build a small sin/cos table for my
- matrix rotation :)
-
- speaking of math... any idea how to find an aproximation of the curve
- y = 1/(1/x) = x^2 using an incremental methode like: y = x+a , a+=b ?
- (its just that its in my head right at this moment and I'm blank :)
-
- Stephan
-
- ;------------------------------------------------------------------------------
- ;
- ; INPUT: d0.l = Angle in radian
- ;
- ; OUTPUT: d0.l = sin(A) 29bit precision
- ;
- ; NOTE: The CORDIC algorithms with the setting for sin hardcoded.
- ; This function trash d2-d6.
- ;
- fractionBits = 14
- HalfPi = 843314856
-
- Sin:
- move.l #$136e9db3>>(29-fractionBits),d4 ;X
- move.l d0,d1 ;Z
- moveq #0,d0 ;Y
- moveq #0,d3 ;i
- lea (.atan,pc),a0
- moveq #fractionBits-1,d2
- .Loop0 move.l d4,d5
- move.l d0,d6 ;
- asr.l d3,d5 ;x = X>>i
- asr.l d3,d6 ;y = Y>>i
- addq.l #1,d3 ;i++
- sub.l d6,d4 ;X-=y
- add.l d5,d0 ;Y+=x
- sub.l (a0)+,d1 ;Z-=atan[i]
- blt.b 1$
- 0$ dbra d2,.Loop0
- rts
- .Loop1 move.l d4,d5
- move.l d0,d6
- asr.l d3,d5 ;x = X>>i
- asr.l d3,d6 ;y = Y>>i
- addq.l #1,d3 ;i++
- add.l d6,d4 ;X+=y
- sub.l d5,d0 ;Y-=x
- add.l (a0)+,d1 ;Z+=atan[i]
- bge.b 0$
- 1$ dbra d2,.Loop1
- rts
- .atan dc.l $1921fb54,$0ed63382,$07d6dd7e,$03fab753,$01ff55bb,$00ffeaad,$007ffd55,$003fffaa
- dc.l $001ffff5,$000ffffe,$0007ffff,$00040000,$00020000,$00010000,$00008000,$00004000
- dc.l $00002000,$00001000,$00000800,$00000400,$00000200,$00000100,$00000080,$00000040
- dc.l $00000020,$00000010,$00000008,$00000004,$00000002,$00000001
-
-